package com.hspedu.newData.dmsxl.哈希表;

import org.junit.Test;

import java.util.ArrayList;
import java.util.List;

/**
 * @Author: yh
 * @description: 
 * @CreateTime: 2025-05-12 
 * @Version: 1.0
 */

public class LC2094找出3位偶数 {
    public int[] findEvenNumbers(int[] digits) {

        int[] map = new int[10];

        int len = digits.length;
        for (int i = 0; i < len; i++) {
            map[digits[i]]++;
        }

        List<Integer> list = new ArrayList<>();

        for (int i = 100; i < 1000; i+=2) {

            int[] nums = new int[10];

            int m = i%1000/100; // 百位
            int n = i%100/10; // 十位
            int k = i%10; // 个位
            nums[m]++;
            nums[n]++;
            nums[k]++;

            boolean loop = true;

            for (int j = 0; j < 10; j++) {
                if (map[j] < nums[j]){
                   loop = false;
                   break;
                }
            }

            if (loop){
                list.add(i);
            }
        }

        int[] result = new int[list.size()];

        for (int i = 0; i < list.size(); i++) {
            result[i] = list.get(i);
        }

        return result;
    }


    @Test
    public void test() {
        // 测试代码

        findEvenNumbers(new int[]{2,1,3,0});
        findEvenNumbers(new int[]{2,2,8,8,2});

    }
}
